Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / database / src / commonMain / kotlin / org / meshtastic / core / database / entity / BootloaderOtaQuirksCacheEntity.kt

Displaying Raw • Download

core/database/src/commonMain/kotlin/org/meshtastic/core/database/entity/BootloaderOtaQuirksCacheEntity.kt 4651c85361d890ee3b0ac02ea3fc5b185e97033e (4651c853) Text, 2.98 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.database.entity

Tff7b72import T7ee787androidx.room3.ColumnInfo
Tff7b72import T7ee787androidx.room3.Entity
Tff7b72import T7ee787androidx.room3.PrimaryKey
Tff7b72import T7ee787kotlinx.serialization.Serializable
Tff7b72import T7ee787kotlinx.serialization.json.Json
Tff7b72import T7ee787org.meshtastic.core.model.BootloaderOtaQuirk
Tff7b72import T7ee787org.meshtastic.core.model.BootloaderOtaQuirksResponse
Tff7b72import T7ee787org.meshtastic.core.model.SoftDeviceVariantEntry

T8b949e/** Lenient so decoding a cached column survives a model that gained fields since it was written (forward-compat). */
Tff7b72private Tff7b72val Te6edf3entityJson Tff7b72= Te6edf3Json Tb4b4b4{ Te6edf3ignoreUnknownKeys Tff7b72= Tff7b72true Tb4b4b4}

T8b949e/**
* Single-row cache of the nRF52 bootloader/OTA quirk catalog (`/resource/bootloaderOtaQuirks`), pre-serialized rather
* than modeled as per-row tables — the only two readers (`applyBootloaderQuirk`/`applySoftDeviceVariant` in
* `DeviceHardwareRepositoryImpl`) always want the whole envelope and filter it in Kotlin, so a granular schema would
* add migration surface for no query anyone runs. [id] is always [SINGLETON_ID]; this table only ever holds one row.
*/
Tf0883e@Serializable
Tf0883e@EntityTb4b4b4(Te6edf3tableName Tff7b72= Ta5d6ff"Ta5d6ffbootloader_ota_quirks_cacheTa5d6ff"Tb4b4b4)
Tff7b72data Tff7b72class T56d364BootloaderOtaQuirksCacheEntityTb4b4b4(
Tf0883e@PrimaryKey Tff7b72val Te6edf3idTb4b4b4: Tffa657Int Tff7b72= Te6edf3SINGLETON_IDTb4b4b4,
Tf0883e@ColumnInfoTb4b4b4(Te6edf3name Tff7b72= Ta5d6ff"Ta5d6ffdevices_jsonTa5d6ff"Tb4b4b4) Tff7b72val Te6edf3devicesJsonTb4b4b4: Tffa657String Tff7b72= Ta5d6ff"Ta5d6ff[]Ta5d6ff"Tb4b4b4,
Tf0883e@ColumnInfoTb4b4b4(Te6edf3name Tff7b72= Ta5d6ff"Ta5d6ffsoft_device_variants_jsonTa5d6ff"Tb4b4b4) Tff7b72val Te6edf3softDeviceVariantsJsonTb4b4b4: Tffa657String Tff7b72= Ta5d6ff"Ta5d6ff[]Ta5d6ff"Tb4b4b4,
Tb4b4b4) Tb4b4b4{
Tff7b72companion Tff7b72object Tb4b4b4{
Tff7b72const Tff7b72val Te6edf3SINGLETON_ID Tff7b72= T79c0ff0
Tb4b4b4}
Tb4b4b4}

Tff7b72fun Te6edf3BootloaderOtaQuirksResponseTb4b4b4.Td2a8ffasEntityTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3BootloaderOtaQuirksCacheEntityTb4b4b4(
Te6edf3devicesJson Tff7b72= Te6edf3entityJsonTb4b4b4.Te6edf3encodeToStringTb4b4b4(Te6edf3devicesTb4b4b4)Tb4b4b4,
Te6edf3softDeviceVariantsJson Tff7b72= Te6edf3entityJsonTb4b4b4.Te6edf3encodeToStringTb4b4b4(Te6edf3softDeviceVariantsTb4b4b4)Tb4b4b4,
Tb4b4b4)

T8b949e// A malformed column value decodes to an empty list rather than propagating the failure — consistent with the
T8b949e// bundled-asset seed path, and safe for the same reason: an empty softDeviceVariants list still resolves every
T8b949e// hwModel to `null`, which refuses.
Tff7b72fun Te6edf3BootloaderOtaQuirksCacheEntityTb4b4b4.Td2a8ffasExternalModelTb4b4b4(Tb4b4b4) Tff7b72= Te6edf3BootloaderOtaQuirksResponseTb4b4b4(
Te6edf3devices Tff7b72=
Te6edf3runCatching Tb4b4b4{ Te6edf3entityJsonTb4b4b4.Te6edf3decodeFromStringTff7b72<Te6edf3ListTff7b72<Te6edf3BootloaderOtaQuirkTff7b72>Tff7b72>Tb4b4b4(Te6edf3devicesJsonTb4b4b4) Tb4b4b4}
Tb4b4b4.Te6edf3getOrDefaultTb4b4b4(Te6edf3emptyListTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4,
Te6edf3softDeviceVariants Tff7b72=
Te6edf3runCatching Tb4b4b4{ Te6edf3entityJsonTb4b4b4.Te6edf3decodeFromStringTff7b72<Te6edf3ListTff7b72<Te6edf3SoftDeviceVariantEntryTff7b72>Tff7b72>Tb4b4b4(Te6edf3softDeviceVariantsJsonTb4b4b4) Tb4b4b4}
Tb4b4b4.Te6edf3getOrDefaultTb4b4b4(Te6edf3emptyListTb4b4b4(Tb4b4b4)Tb4b4b4)Tb4b4b4,
Tb4b4b4)

Served by rngit 1.5.3 - Generated in 0.06s